package day2_linkedlist.leetcode;

/**
 * @author yuisama
 * @date 2021/12/25 13:52
 **/
public class Test {
    public static void main(String[] args) {
        int[] arr = {4,2,1,3};
        ListNode head = build(arr);
        ListNode newHead = new Num148().sortList(head);
        System.out.println(newHead);
    }

    /**
     * 将arr数组的值变为链表
     * @param arr
     * @return
     */
    public static ListNode build(int[] arr) {
        ListNode dummyHead = new ListNode(-1);
        ListNode tail = dummyHead;
        for (int i = 0; i < arr.length; i++) {
            ListNode node = new ListNode(arr[i]);
            tail.next = node;
            tail = node;
        }
        return dummyHead.next;
    }
}